<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        input{
            width: 200px;
            height: 40px;
        }
        body {
            text-align: center;
            background-color: rgba(255, 192, 203, 1);
        }

        #username {
            border-radius: 50px;
            text-align: center;
            border: none;
            outline: none;
        }

        #password {
            border-radius: 50px;
            text-align: center;
            border: none;
            /* 去掉外轮廓 */
            outline: none;
        }

        #in3 {
            border-radius: 50px;
            text-align: center;
            border: none;
            width: 70px;
            height: 20px;
            outline: none;
            background-color: yellow;
        }

        #h1 {
            font-size: 50px;
            color: #FFFF;
            margin-top: 200px;
        }
    </style>
</head>

<body>
        <h1 id="h1">Welcome</h1>
        <form action="">
            <input id="username" type="text" placeholder="请输入账号"><br>
            <br>
            <input id="password" type="password" placeholder="请输入密码"><br>
            <br>
            <button id="in3" type="button" onclick="denglu()">登录</button>
            <a href="注册页面.html">没有账号?去注册</a>
        </form>
        
        <script>
            function denglu(){
                // 获取输入框数据
                var username = document.querySelector("#username").value;
                var password = document.querySelector("#password").value;                
                // 2.获取localstrage里面的数据
                var username2 = localStorage.getItem("username");
                var password2 = localStorage.getItem("password");

                // 3.判断
                if(username==username2){
                    if(password==password2){
                        alert("登录成功");
                        location.href = "首页.html";
                    }else{
                        alert("密码错误！");
                    }
                }else{
                    alert("账户名错误！");
                }
            }
        </script>
</body>

</html>